package cn.itcast.activitylifecycle;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class SecondActivity extends AppCompatActivity {
    private Button btn_two;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        btn_two = (Button) findViewById(R.id.btn_two);
        Intent intent = getIntent();
        String info = intent.getStringExtra("Info");
        Toast.makeText(SecondActivity.this, info, Toast.LENGTH_SHORT).show();
        btn_two.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent2 = new Intent();
                intent2.putExtra("BackInfo", info + info);
                setResult(Activity.RESULT_OK, intent2);
                finish();
            }
        });
    }
}